<?php

function list_text_seting(){
	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'),  
		'KONSTANTA'=>array('style'=>'border-bottom:2px solid;width:35%'), 
		'DEFINISI'=>array('style'=>'border-bottom:2px solid;width:40%'), 
		' '=>array('style'=>'border-bottom:2px solid;width:10%'), 
	);
	$query = "SELECT * FROM seting_label ORDER BY sort_id ASC";
	$result = my_query($query);
$i=0;
	while($ey = my_fetch_array($result) ){
$i++;		$editproperty = array(
			'href'=>'index.php?com='.$_GET['com'].'&task=edit_msg&label='.$ey['label'],
			'rel'=>'facebox',
			'title'=>'Edit'
		);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$row[] = array(
				'#'=>position_text_align ($i, 'center'), 
				'singkat'=>  $ey['label'] ,   
				'bank'=>  $ey['value'] ,   
				'operasi'=> position_text_align(  $edit_button  , 'right'),  
			);
		 
	}
	
	$datas = table_rows($row);   
	return table_builder($header , $datas ,  3 , false );
}


function form_edit($label){
	$view = form_header( "bank" , "bank"  ); 
	$query = "SELECT * FROM seting_label WHERE label ='{$label}' LIMIT 1";
	$result = my_query($query);
	$row = my_fetch_array($result);
	
	$view .= form_field_display( $row['label']  , "KONSTANTA"   );	

	$temp = array(
		'name'=>'value',
		'value'=>( isset($_POST['value']) ? $_POST['value'] : $row['value'] ),
		'id'=>'value',
		'type'=>'text',
		'size'=>'45'
	);
	$form_temp = form_dynamic($temp);	
	$view .= form_field_display( $form_temp   , "DEFINISI"   );
	
	$submit = array(
		'value' => (  '  Ganti  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 	
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
}

function submit_msg($label){
	$value = trim($_POST['value']);
	$query = "UPDATE seting_label SET value='{$value}' WHERE label='{$label}'";
	return my_query($query);
}